<template>
  <view class="container">
    <NavBar title="编辑个人资料"></NavBar>
    <UploadImg></UploadImg>
    <BaseInfo></BaseInfo>
	<view class="btn">
		<u-button type="success" text="保存信息" @click="submit"></u-button>
		<text class="tip">(注:头像与用户信息,需点击保存后生效)</text>
	</view>
  </view>
</template>

<script>
import UploadImg from './components/UploadImg.vue'
import BaseInfo from './components/BaseInfo.vue'
export default {
  components: {
    UploadImg,
    BaseInfo
  },
  computed: {
  	user() {
  		return this.$store.state.auth.userInfo
  	}
  },
  methods:{
		async submit () {
			const {code,msg} = await this.$axios.api.updateUserInfo({
				nickname:this.user.nickname,
				pic:this.user.pic,
				location:this.user.location,
				gender:this.user.gender,
				sign:this.user.sign
			})
			if(code === 200){
			  uni.showToast({
				  title:msg,
				  icon:'success',
				  duration:2000
			  })
			}else{
			  uni.showToast({
				  title:msg,
				  icon:'none',
				  duration:2000
			  })
			}
		}
  }
}
</script>

<style lang="scss" scoped>
/* #ifndef APP-NVUE */
::v-deep .u-image{
			width: 180rpx;
			height: 180rpx;
			display: flex;
			justify-content: center;
			align-items: center;
		}
/* #endif */
.container {
  height: 100%;
  background-color: rgba(31, 182, 131, 0.2);
  display: flex;
  flex-direction: column;
  align-items: center;
  .btn{
	  margin-top: 20rpx;
	  width: 80%;
	  height: 120rpx;
	  display: flex;
	  flex-direction: column;
	  justify-content: space-around;
	  align-items: center ;
	  .tip{
		font-size: 24rpx;
		color: #666666;
	  }
  }
}
</style>
